import { ElMessage } from 'element-plus'
import router from "@/router";
export const returnMsg = async promise => {
    try {
        const res = await promise
        if (res.code === 1) {
            return res.data
        } if (res.code === 2) {
            ElMessage.error(res.msg)
            setTimeout(() => {
                router.push('/login')
            }, 1000)
        } else {
            ElMessage.error(res.msg)
            return
        }
    } catch (e) {
        console.log(e.name + '====' + e.message)
        if (e.message.indexOf('404') !== -1) {
            return ''
        }
        ElMessage.error('网络请求错误，请联系系统管理员')
        return ''
    }
}
